<%--
  Created by IntelliJ IDEA.
  User: bin.liu
  Date: 2018/12/5
  Time: 16:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<jsp:include page="/pages/sysIndex/default.jsp"/>
<div class="main-content">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-trophy"></i>工艺列表
            </div>
            <div class="box-tools pull-right">


                <a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
            </div>
        </div>

        <div class="box-body">
            <form id="searchForm" action="<c:url value="/web/admin/plannerOrder/maintainJson.action"/>" method="post"
                  class="form-inline hide" data-page-no="1" data-page-size="20" data-order-by="">
                <div class="form-group">
                    <label class="control-label">搜索：</label>
                    <div class="control-inline">
                        <input type="text" id="searchCode" name="searchCode" value="" maxlength="64"
                               class="form-control width-120">
                        <input type="hidden" name="plannerId" id="plannerId" value="${plannerId}"/>
                        <input type="hidden" name="facilityMaintainIds" id="facilityMaintainIds"
                               value="${facilityMaintainIds}"/>
                        <input type="hidden" name="facilityCatId" id="facilityCatId"
                               value="${facilityCatId}"/>
                    </div>
                </div>


                <div class="form-group">
                    <button type="submit" class="btn btn-primary btn-sm">查询</button>
                    <button type="reset" class="btn btn-default btn-sm">重置</button>
                </div>
            </form>
            <div style="overflow-x:auto">
                <table id="dataGrid"></table>
            </div>
            <div id="dataGridPage"></div>
            <div class="box-footer">
                <div class="row">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i
                                class="fa fa-check"></i>
                            保 存
                        </button>&nbsp;

                        <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="closeView()"><i
                                class="fa fa-times"></i> 关 闭
                        </button>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
<script>
    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        shrinkToFit: false,
        autoScroll: true,
        columnModel: [
            {header: '流水号', name: 'code', index: 'code', width: 100, align: "center",sortable: false},
            {header: '所属专业', name: 'facilityCatName', index: 'facilityCat', width: 100, align: "center",sortable: false},
            {header: '设备类别', name: 'facilityCatName', index: 'facilityCat', width: 100, align: "center",sortable: false},
            {header: '保养名称', name: 'name', index: 'name', width: 100, align: "center",sortable: false},
            {header: '所属部门', name: 'organizationName', index: 'organization', width: 100, align: "center",sortable: false},
            {header: '施工准备工作', name: 'prepareWork', index: 'prepareWork', width: 100, align: "center",sortable: false},
            {header: '预计工时', name: 'estimateTime', index: 'estimateTime', width: 100, align: "center",sortable: false},
            {header: '技能要求', name: 'requireSkill', index: 'requireSkill', width: 100, align: "center",sortable: false},
            {header: '所属企业', name: 'enterpriseName', index: 'enterprise', width: 100, align: "center",sortable: false},
            <%--{--%>
            <%--header: '操作',--%>
            <%--name: 'actions',--%>
            <%--width: 100,--%>
            <%--sortable: false,--%>
            <%--title: false,--%>
            <%--formatter: function (val, obj, row, act) {--%>
            <%--var editUrl='<c:url value="/web/admin/maintainTechnology/editPage.action?id="/>'+row.id;--%>
            <%--return '<a href="javascript:;" class="btn btn-default btn-xs btnList" onclick="vLayuiUtil.openLayerMaxWindow(\'wMaintainTechnology\', \''+editUrl+'\',\'编辑\')"><i class="fa fa-pencil">编辑</i></a>&nbsp;';--%>
            <%--}--%>
            <%--}--%>

        ],
        // 加载成功后执行事件
        ajaxSuccess: function (data) {

        }
    });

    $("#btnSubmit").click(function () {
        var id = $("#dataGrid").jqGrid("getGridParam", "selrow");
        console.log(id);
        if (id == null || id == "") {
            js.showMessage("请选择工作内容");
        }
        $.ajax({
            type: 'post',
            url: "<c:url value="/web/admin/plannerOrder/showMaintain.action"/>",
            data: {
                "maintainId": id,
                "plannerId": $("#plannerId").val(),
                "facilityMaintainIds": $("#facilityMaintainIds").val()
            },
            dataType: 'json',
            async: false,
            success: function (data) {
                js.showMessage(data.msg);
                closeView();
                parent.$("#facilityMaintainDataGrid").jqGrid().setGridParam({datatype: 'json'}).trigger('reloadGrid');

            },
            error: function () {
                js.showMessage("出错了，请联系管理员");
            }
        });

    })

    function closeView() {
        console.log("关闭");
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);

    }
</script>